package com.arch.hdfs.tfile;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.MapFile;

/**
 * @author pizhihui
 * @date 2024-06-05 16:20
 */
public class MapFileDemo {


    public static void main(String[] args) {


        Configuration conf = new Configuration();
        Path path = new Path("file:///tmp/file");
        ;

        try(FileSystem fs = path.getFileSystem(conf);
                MapFile.Writer writer = new MapFile.Writer(conf, fs, "/tmp/file", BytesWritable.class, BytesWritable.class);) {


            BytesWritable key = new BytesWritable("key1".getBytes());
            BytesWritable val = new BytesWritable("hello".getBytes());
            writer.append(key, val);

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

}
